#include "visitor.h"

void SfVisitor::visitStomachMdc(StomachMed *stomac_mdc)
{
    std::cout << "stomach medicine price:" << stomac_mdc->getPrice() << std::endl;
    m_totalPrice+= stomac_mdc->getPrice();
}

void SfVisitor::visitColdMdc(ColdMed *cold_mdc)
{
    std::cout << "cold medicine price:" << cold_mdc->getPrice() << std::endl;
    m_totalPrice+= cold_mdc->getPrice();
}

void SfVisitor::visitAntiInflammatoryMdc(AntiInflammatoryMed *antiInflammatory_mdc)
{
    std::cout << "anti inflammatory medicine price:" << antiInflammatory_mdc->getPrice() << std::endl;
    m_totalPrice+= antiInflammatory_mdc->getPrice();
}

void QyVisitor::visitStomachMdc(StomachMed *stomac_mdc)
{
    std::cout <<stomac_mdc->getName() << "已经取到" << std::endl;
}

void QyVisitor::visitColdMdc(ColdMed *stomac_mdc)
{
    std::cout <<stomac_mdc->getName() << "已经取到" << std::endl;
}

void QyVisitor::visitAntiInflammatoryMdc(AntiInflammatoryMed *stomac_mdc)
{
    std::cout <<stomac_mdc->getName() << "已经取到" << std::endl;
}

void StomachMed::accept(Visitor *vistor)
{
    if(vistor)
        vistor->visitStomachMdc(this);
}

void ColdMed::accept(Visitor *vistor)
{
    if(vistor)
        vistor->visitColdMdc(this);
}

void AntiInflammatoryMed::accept(Visitor *vistor)
{
    if(vistor)
        vistor->visitAntiInflammatoryMdc(this);
}
